﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:common="clr-namespace:YourLastOptionsDialog.Common"
             xmlns:ylodcontrols="clr-namespace:YourLastOptionsDialog.Controls"
             mc:Ignorable="d"
             x:Class="YourLastOptionsDialog.Views.PasswordEditor"
             d:DesignWidth="480"
             d:DesignHeight="800">
    <UserControl.Resources>
        <common:StringToVisibilityConverter x:Key="StringToVisibilityConverter" />
        <common:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
    </UserControl.Resources>

    <Grid x:Name="LayoutRoot"
          Background="Transparent"
          Margin="12,0,0,20"
          VerticalAlignment="Top">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <StackPanel Orientation="Vertical"
                    Margin="0,0,0,0"
                    VerticalAlignment="Top">
            <TextBlock x:Name="DisplayNameTextBlock"
                       Margin="0,0,0,0"
                       TextWrapping="Wrap"
                       Text="{Binding DisplayName}"
                       Style="{StaticResource PhoneTextNormalStyle}" />
            <TextBlock x:Name="DescriptionTextBlock"
                       Margin="0"
                       TextWrapping="Wrap"
                       Visibility="{Binding Description, Converter={StaticResource StringToVisibilityConverter}}"
                       Text="{Binding Description}"
                       Style="{StaticResource PhoneTextNormalStyle}">
                <TextBlock.Foreground>
                    <SolidColorBrush Color="{StaticResource PhoneDisabledColor}" />
                </TextBlock.Foreground>
            </TextBlock>
        </StackPanel>
        <ylodcontrols:ValidatingPasswordBox x:Name="ValidatingPasswordBox"
                                            Margin="0"
                                            Password="{Binding TextValue}"
                                            Validator="{Binding Validator}"
                                            PasswordChanged="ValidatingPasswordBox_OnPasswordChanged"
                                            d:LayoutOverrides="Height"
                                            Grid.Row="1"
                                            VerticalAlignment="Top"
                                            HorizontalAlignment="Stretch" />

        <TextBlock x:Name="ConfirmationDescriptionTextBlock"
                   Grid.Row="2"
                   Margin="0"
                   TextWrapping="Wrap"
                   Visibility="{Binding ShowConfirmation, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=False}"
                   Text="{Binding ConfirmationDescription}"
                   Style="{StaticResource PhoneTextNormalStyle}">
            <TextBlock.Foreground>
                <SolidColorBrush Color="{StaticResource PhoneDisabledColor}" />
            </TextBlock.Foreground>
        </TextBlock>
        <ylodcontrols:ValidatingPasswordBox x:Name="ConfirmationValidatingPasswordBox"
                                            Grid.Row="3"
                                            Margin="0"
                                            Password="{Binding ConfirmationPassword}"
                                            ValidationErrorMessage="{Binding PasswordsDoNotMatchErrorMessage}"
                                            Visibility="{Binding ShowConfirmation, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=False}"
                                            PasswordChanged="ConfirmationValidatingPasswordBox_OnPasswordChanged"
                                            d:LayoutOverrides="Height"
                                            VerticalAlignment="Top"
                                            HorizontalAlignment="Stretch" />
    </Grid>
</UserControl>